package nl.depository.pim.components;

import nl.depository.pim.pages.Index;
import nl.depository.pim.services.Authenticator;

import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SetupRender;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.Request;

public class Layout
{
    @SuppressWarnings("unused")
	@Property
    @Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)
    private String pageTitle;
    
    @Inject
    private Authenticator authenticator;
    
    @SuppressWarnings("unused")
    @Property
	@Inject
    private Request request;
    
	@SetupRender
	final void renderDocType(final MarkupWriter writer)
	{
		// Output the HTML5 doctype, as a work-around to https://issues.apache.org/jira/browse/TAP5-1040
		writer.getDocument().raw("<!DOCTYPE html>\n");
	}
	
	public Object onActionFromLogout()
	{
		authenticator.logout();
		return Index.class;
	}
}
